<!DOCTYPE html>
<html>

<head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
</head>

<body>
<form id="form1" action="/prod-api/common/upload/token" target="frame1" method="post" enctype="multipart/form-data">
    文件上传
    <input type="file" name="file">
    <input type="button" value="上传" onclick="upload()">
</form>
<iframe name="frame1" frameborder="0" height="40"></iframe>
<!-- 其实我们可以把iframe标签隐藏掉 -->
<script type="text/javascript">
    // 	function getUrlParam(name) {
    //     //分割参数
    //     var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    //     var r = window.location.search.substr(1).match(reg); //匹配目标参数
    //     if (r != null) {
    //       return r[2];
    //     }
    //     return null; //返回参数值
    //   }
    //   var token = getUrlParam("tokenId");
    function upload() {
        $("#form1").submit();
        var t = setInterval(function () {
            //获取iframe标签里body元素里的文字。即服务器响应过来的"上传成功"或"上传失败"
            var word = JSON.parse($("iframe[name='frame1']").contents().find("body").text());
            console.log(word)
            if (word != "") {
                clearInterval(t); //清除定时器
                var title = '本地文档打印';
                var chicun = '2100mm*2970mm';
                var content = word.url;
                setTimeout(function () {
                    wx.miniProgram.navigateTo({url: '/modelA/pages/documents_printing/picplace_order/picplace_order?title=' + title + '&chicun=' + chicun + '&content=' + content + '&id=14'})
                }, 400);
            }
        }, 1000);
    }
</script>
</body>
</html>
